<script src="${resource(dir:'js/lli',file:'ErrorManager.js')}"></script>
<script src="${resource(dir:'js/lli',file:'FileManager.js')}"></script>
<script>
   var onFileUploadReady = function(){
     var oSubmitFileButton = new YAHOO.widget.Button("submitFileUpload");
     oSubmitFileButton.on("click",function(){
           var c = YAHOO.util.Connect;
           c.setForm(document.getElementById("fileUpload"), true);
           var success = function(o){
             var filesUp = new YAHOO.util.Element('filesUp');
             if (o.responseXML.getElementsByTagName("list").length > 0){
                var errorManager = new ErrorManager(o.responseXML);
                errorManager.ShowDialogError();
             } else {
                var file = new MFile(o.responseXML, "${createLink(controller:'MFileManager', action:'showFile')}");
                file.appendTo(filesUp);
             }
             
           }
           callback = {
             upload: success,
             failure: function(o){}
           };
           var transaction = c.asyncRequest('POST', '${createLink(controller:"MFileManager", action:"addnewfile")}', callback);
         });
   }
   
   YAHOO.util.Event.onContentReady("submitFileUpload", onFileUploadReady);
</script>
<style>.form-line {margin:6px 0px;}</style>
<div class="addfileform">
  <form name="fileUpload" id="fileUpload" enctype="multipart/form-data">
    <p class="form-line">Name your file : <input type="text" name="name"/>, </p>
    <p class="form-line">choose your file : <input type="file" name="fileup" id="fileup" /></p>
    <div class="actions">
      And finally <input id="submitFileUpload" type="button" value="upload it" />
    </div>
  </form>
</div>